#! /bin/sh
#./script-filtrosServidor.sh ip-cliente ip-servidor servidorPort directTraza

#previamente genere el archivo "traza-servidor.dmp" con
#tshark -i eth0 -w traza-servidor.dmp > as &

#ACKs normales
sudo tshark -R "(ip.src==$1) and (ip.dst==$2)  and (tcp.flags.syn == 0) and !(tcp.len > 0) and (tcp.flags.fin == 0) and (tcp.port ==$3) and !(tcp.analysis.duplicate_ack)" -T fields -e frame.time_relative -e tcp.ack -r /tmp/traza-servidor.dmp > $4/acks1.txt #ACKs

#ACKs Duplicados
sudo tshark -R "(ip.src==$1) and (ip.dst==$2)  and (tcp.flags.syn == 0) and !(tcp.len > 0) and (tcp.flags.fin == 0) and (tcp.port ==$3) and (tcp.analysis.duplicate_ack)" -T fields -e frame.time_relative -e tcp.ack -e tcp.analysis.duplicate_ack_num -r /tmp/traza-servidor.dmp > $4/acks-dup1.txt #ACKs Duplicados

#todos los ACKs
sudo tshark -R "(ip.src==$1) and (ip.dst==$2) and (tcp.flags.syn == 0) and !(tcp.len > 0) and (tcp.flags.fin == 0) and (tcp.port ==$3)" -T fields -e frame.time_relative -e tcp.ack -r /tmp/traza-servidor.dmp > $4/servidor-ACKs.txt #ACKs todos

#todos los DATApkts
sudo tshark -R "(ip.src==$2) and (ip.dst==$1)  and !tcp.segments and (tcp.len > 0) and (tcp.port ==$3)" -T fields -e frame.time_relative -e tcp.seq -r /tmp/traza-servidor.dmp > $4/servidor-DATApkts.txt #DATApkts

#cambiar permisos
sudo chmod -R 777 tr-srv
